package com.ohc.其它.网络编程;

import java.io.*;
import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;

public class GreetingClient {

    public static void main(String[] args) throws UnknownHostException {

        //(1)获取InetAddress的方式
        InetAddress ia = InetAddress.getLocalHost();//本机
        System.out.println("获取主机的Ip地址：" + ia.getHostAddress());
        System.out.println("获取主机名称：" + ia.getHostName());

        //（2）根据域名得到InetAddress对象
        InetAddress ia2 = InetAddress.getByName("http://mp4.yyhgxgy.cn");
        System.out.println("京东服务器的IP地址："+ia2.getHostAddress());
        System.out.println("主机名称："+ia2.getHostName());
    }
}
